package com.snow.auth.entity;

import com.snow.jpa.IBaseEntity;
import com.snow.jpa.ICreateInfoEntity;
import com.snow.jpa.ITenantEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 用户
 *
 * @author by 13119
 */
@Getter
@Setter
@Entity
public class SystemUser implements Serializable, IBaseEntity<Integer>, ITenantEntity, ICreateInfoEntity {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Integer id;
    private Integer deptId;
    private String deptName;
    private String account;
    private String password;
    private String realName;
    private String avatar;
    private String email;
    private String phone;
    /**
     * 创建时间
     */
    private Integer createId;
    private String createName;
    private Date createTime;
    /**
     * 1 正常使用
     * 0 禁用
     */
    @Column(length = 2)
    private Integer status;
    /**
     * 系统管理员
     */
    private Boolean systemAdmin;
    /**
     * 预览用户
     */
    private Boolean previewUser;
    /**
     * 数据权限
     * 0 所有数据
     * 1 本人数据
     * 2 本部门数据
     * 3 本部门及所有子部门数据
     * 4 指定部门数据
     */
    private Integer dataScope;
    /**
     * 租户ID
     */
    private Integer tenantId;
    /**
     * 微信OpenId
     */
    private String openId;
    /**
     * 角色ID数组
     */
    @Transient
    private List<Integer> roleIds;

    @Transient
    private List<Integer> postIds;

    @Getter
    @AllArgsConstructor
    public enum Status {
        normal(1), lock(0);
        final Integer value;
    }

}
